#!/usr/bin/env gawk -f
#Rewrite the .ele output of triangle by removing the first column.
# We have to check for the comments (dont print lines starting with #), 
# and the first line (dont modify it)

# Usage:
#	./ele2mesh < .ele > .mesh
#
# Format input: .ele (from Triangle)
#	First line: <# of triangles> <nodes per triangle> <# of attributes>
#	Remaining lines: <triangle #> <node#> <node#> <node#> ... [attributes]
# With nodes being indices in the corresponding .node file (for coordinates)
# (see triangle -h)
# 
# Format output: .mesh (from metis)
#	First line: <# of elements> <element mark (1=triangle, 2=4sides, ...)> <format> <# of node weights>
#	Remaining lines: <node#> <node#> <node#> (i+1th line corresponds to ith element)
# (see the metis manual for more info on the format)
#
# For the wrekagrid project
# Basile Clout, September 2007

#Change the first line whatever happens, and skip the other steps
FNR == 1 {print $1 "\t1" ; next} 

#print the line if it does not start with a # (comment)
$1 !~ /^\#/ {print $2 "\t" $3 "\t" $4} 
